
import * as THREE from 'three';
import React from 'react';
import Controller from 'Controller';
import { Element } from 'components/Three';
import ICapability from 'components/capability/interfaces/ICapability';
import { TagType } from 'constants/TagType';
import { IObject3DMap } from 'components/Three/interface/IElement';

/** 标准标记 */
export const standard: ICapability<undefined> = {
    id: 'standard',
    title: '标准标记',
    useExpand: () => {

        const onClick = React.useCallback(() => {
            const threeController = Controller.instance.state.threeController;
            const geometry = new THREE.SphereGeometry(0.1);
            const material = new THREE.MeshBasicMaterial({ color: 0xffffff });
            const sphere = new THREE.Mesh(geometry, material);

            const element = new Element<keyof IObject3DMap, { type: TagType }>('tag', sphere.uuid, sphere);
            element.data = { type: TagType.标准 };

            sphere.position.set(0, 0, 0);
            threeController.sceneAdd(element);

            threeController.run(async s => s.selectedElementUuid = element.uuid);
        }, [])

        return {
            onClick,
        }
    }
}